//
//  PPTopicDetailViewController.m
//  PetParadise
//
//  Created by 陈无忌 on 8/31/14.
//  Copyright (c) 2014 whalefin. All rights reserved.
//

#import "PPTopicDetailViewController.h"
#import "PPImageDisplayViewController.h"
#import "PPUserCenterMainPageTableViewController.h"
#import "PPOtherUserCardViewController.h"

#import "PPCommentTableViewCell.h"
#import "PPContentTableViewCell.h"
#import "PPCustomBGTableView.h"

#import "PPSystemConfiguraton.h"
#import "supportingHeadFiles.h"
#import "TTScrollableAds.h"

#import "UMSocial.h"

@interface PPTopicDetailViewController ()<UIGestureRecognizerDelegate,UITextFieldDelegate,UIAlertViewDelegate,UIActionSheetDelegate,UITableViewDataSource,UITableViewDelegate,UMSocialUIDelegate>

@property (weak, nonatomic) IBOutlet UIImageView *userAvatar;
@property (weak, nonatomic) IBOutlet UILabel *publicDateLabel;
//@property (weak, nonatomic) IBOutlet UIImageView *topicImage;
@property (weak, nonatomic) IBOutlet PPCustomBGTableView *commentTableView;
@property (weak, nonatomic) IBOutlet UILabel *topicUserNameLabel;

@property (weak, nonatomic) IBOutlet UIView *headView;

//add comment
@property (weak, nonatomic) IBOutlet UIView *commentView;
@property (weak, nonatomic) IBOutlet UITextField *addCommentTF;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *deleteTopicButton;

@property (strong, nonatomic) NSMutableArray *commentArray;
@property (strong, nonatomic) NSMutableArray *imageArray;

@property (weak, nonatomic) PPSystemConfiguraton *config;

@property (nonatomic) BOOL isKeyBoardShow;
@property (nonatomic) BOOL isFirstLoadKeyBoard;
@property (nonatomic) int replyTargetId;//直接回复为0

//
@property (weak, nonatomic) IBOutlet UILabel *likeCountLabel;
@property (weak, nonatomic) IBOutlet UILabel *commentLabel;

@property (weak, nonatomic) IBOutlet UIButton *likeButton;

@property (weak, nonatomic) IBOutlet UIScrollView *imagePlayerView;
@property (weak, nonatomic) IBOutlet UIPageControl *pageControl;
@property (strong, nonatomic) NSMutableArray *imgHeightArray;

@end

@implementation PPTopicDetailViewController

- (NSMutableArray *)imgHeightArray
{
    if (!_imgHeightArray) {
        _imgHeightArray = [NSMutableArray array];
    }
    return _imgHeightArray;
}

-(PPSystemConfiguraton *)config
{
    if (!_config) {
        _config = [PPSystemConfiguraton sharedSystemConfiguration];
    }
    return _config;
}

-(void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    
    if ([self.commentTableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.commentTableView setSeparatorInset:UIEdgeInsetsZero];
    }
    
    if ([self.commentTableView respondsToSelector:@selector(setLayoutMargins:)]) {
        [self.commentTableView setLayoutMargins:UIEdgeInsetsZero];
    }
}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:YES];
    if ([self.addCommentTF isFirstResponder]) {
        [self.addCommentTF resignFirstResponder];
    }
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.addCommentTF.delegate = self;
    self.commentTableView.delegate = self;
    self.commentTableView.dataSource = self;
    self.commentTableView.tableHeaderView = self.headView;
    
    self.commentView.hidden = YES;
    [self getTopic];
    self.isKeyBoardShow = NO;
    self.replyTargetId = 0;
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillShow:)
                                                 name:UIKeyboardWillShowNotification
                                               object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardDidShow:)
                                                 name:UIKeyboardDidShowNotification
                                               object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillHide:)
                                                 name:UIKeyboardWillHideNotification
                                               object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardDidHide:)
                                                 name:UIKeyboardDidHideNotification
                                               object:nil];
}

- (void)setImagePlayerView
{
    self.imagePlayerView.bounces = YES;
    self.imagePlayerView.pagingEnabled = YES;
    self.imagePlayerView.delegate = self;
    self.imagePlayerView.userInteractionEnabled = YES;
    self.imagePlayerView.showsHorizontalScrollIndicator = NO;
    
    [self.pageControl setCurrentPageIndicatorTintColor:[UIColor blackColor]];
    [self.pageControl setPageIndicatorTintColor:[UIColor grayColor]];
    self.pageControl.numberOfPages = [self.imageArray count];
    self.pageControl.currentPage = 0;

    [self.imgHeightArray removeAllObjects];
    for (int i = 0;i<[self.imageArray count];i++)
    {
        PPTopicImage *img = [self.imageArray objectAtIndex:i];
        NSData *data = [NSData dataWithContentsOfURL:[PPImageUrl getImageUrlOriginal:img.img]];
        UIImage *displayImg = [UIImage imageWithData:data];
        double displayHeight = 320 * displayImg.size.height / displayImg.size.width;
        [self.imgHeightArray addObject:@(displayHeight)];
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake((320 * i), 0, 320, displayHeight)];
        [imageView setContentMode:UIViewContentModeScaleAspectFill];
        [imageView setClipsToBounds:YES];
        [imageView setImageWithURL:[PPImageUrl getImageUrlOriginal:img.img] placeholderImage:[UIImage imageNamed:@"defaultAvatar"] usingActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
        [self.imagePlayerView addSubview:imageView];
    }
    
    double firstHeight = [self.imgHeightArray.firstObject doubleValue];
    [self.imagePlayerView setContentSize:CGSizeMake(320 * self.imageArray.count, firstHeight)];
    [self.imagePlayerView scrollRectToVisible:CGRectMake(320 * self.pageControl.currentPage,0,320,firstHeight) animated:NO];
}

- (void)scrollViewDidScroll:(UIScrollView *)sender
{
    if ([sender isEqual:self.imagePlayerView]) {
        CGFloat pagewidth = self.imagePlayerView.frame.size.width;
        int page = floor((self.imagePlayerView.contentOffset.x - pagewidth/2)/pagewidth) + 1;
        self.pageControl.currentPage = page;
        
        //change
        double height = [[self.imgHeightArray objectAtIndex:page] doubleValue];
        CGRect frame = self.headView.frame;
        frame.size.height = 86 + height;
        if (self.headView.frame.size.height != frame.size.height) {
            self.headView.frame = frame;
            self.commentTableView.tableHeaderView = self.headView;
            [self.imagePlayerView setContentSize:CGSizeMake(320 * self.imageArray.count, height)];
        }
    }
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}


- (void)keyboardDidShow:(NSNotification *)notification
{
    self.isKeyBoardShow = YES;
}

- (void)keyboardDidHide:(NSNotification *)notification
{
    self.isKeyBoardShow = NO;
}

-(void)keyboardWillShow:(NSNotification *)notification
{
    self.commentView.hidden = NO;
    NSDictionary* userInfo = [notification userInfo];
    [UIView beginAnimations: @"animateTextField" context: nil];
    [UIView setAnimationBeginsFromCurrentState: YES];
    [UIView setAnimationDuration: 0.3f];
    CGSize keyboardSizeE = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
    CGSize keyboardSize = keyboardSizeE;
    CGRect tableframe = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)  ;
    tableframe.size.height = tableframe.size.height - keyboardSize.height - 44;
    self.commentTableView.frame = tableframe;
    CGRect commentframe = CGRectMake(0, self.view.frame.size.height - 44, 320, 44);
    commentframe.origin.y -= keyboardSize.height;
    self.commentView.frame = commentframe;
    [UIView commitAnimations];
}

-(void)keyboardWillHide:(NSNotification *)notification
{
    if (self.isKeyBoardShow) {
        self.commentView.hidden = YES;
        NSDictionary* userInfo = [notification userInfo];
        [UIView beginAnimations: @"animateTextField" context: nil];
        [UIView setAnimationBeginsFromCurrentState: YES];
        [UIView setAnimationDuration: 0.2f];
        // get the size of the keyboard
        CGSize keyboardSize = [[userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
        // resize tableview
        CGRect frame = self.commentTableView.frame;
        frame.size.height += keyboardSize.height + 44;
        self.commentTableView.frame = frame;
        // set footer's frame
        frame = self.commentView.frame;
        frame.origin.y += keyboardSize.height;
        self.commentView.frame = frame;
        [UIView commitAnimations];
    }
}

-(void)viewInit
{
    PPUserInfo *user = (PPUserInfo *)self.topic.userList.firstObject;
    self.topicUserNameLabel.text = user.userName;
    //navigation rightButton
    if (user.id == self.config.userInfo.id) {
        [self.deleteTopicButton setImage:[UIImage imageNamed:@"delete"]];
        self.deleteTopicButton.enabled = YES;
    }else{
        [self.deleteTopicButton setImage:nil];
        self.deleteTopicButton.enabled = NO;
    }
    //user
    [self.userAvatar setImageWithURL:[PPImageUrl getImageUrl:user.userAvatar] placeholderImage:[UIImage imageNamed:@"defaultAvatar"] usingActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSDate *pubDate = [formatter dateFromString:self.topic.publicDate];
    [formatter setDateFormat:@"yyyy/MM/dd"];
    NSString *pubDateStr = [formatter stringFromDate:pubDate];
    
    
    self.publicDateLabel.text = [NSString stringWithFormat:@"发布于%@",pubDateStr];
    //image player
    [self setImagePlayerView];
    //add gesture
    UITapGestureRecognizer *avatarRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(goInfo)];
    avatarRecognizer.numberOfTouchesRequired = 1;
    avatarRecognizer.numberOfTapsRequired = 1;
    self.userAvatar.userInteractionEnabled = YES;
    [self.userAvatar addGestureRecognizer:avatarRecognizer];
    
    UITapGestureRecognizer *imageRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(showImage)];
    imageRecognizer.numberOfTouchesRequired = 1;
    imageRecognizer.numberOfTapsRequired = 1;
    self.imagePlayerView.userInteractionEnabled = YES;
    [self.imagePlayerView addGestureRecognizer:imageRecognizer];
    //view
    self.likeCountLabel.text = [NSString stringWithFormat:@"%@",@(self.topic.topicLikeNum.count)];
    self.commentLabel.text = [NSString stringWithFormat:@"%@",@(self.topic.replyNum.count)];
    
    BOOL isLike = NO;
    for (NSDictionary *likeDic in self.topic.topicLikeNum) {
        int likeUser = [likeDic[@"userId"] intValue];
        if (likeUser == self.config.userInfo.id) {
            isLike = YES;
            break;
        }
    }
    if (isLike) {
        if (self.config.userInfo.gender == USER_MALE) {
            [self.likeButton setImage:[UIImage imageNamed:@"blueHeart"] forState:UIControlStateNormal];
        }else{
            [self.likeButton setImage:[UIImage imageNamed:@"redHeart"] forState:UIControlStateNormal];
        }
    }else{
        [self.likeButton setImage:[UIImage imageNamed:@"whiteHeart"] forState:UIControlStateNormal];
    }
}

- (void)goUserCard:(UITapGestureRecognizer *)sender
{
    UITapGestureRecognizer *tap = sender;
    UIImageView *image= (UIImageView *)tap.view;
    PPComment *reply = [self.commentArray objectAtIndex:image.tag - 1];
    if (reply.userId == [PPSystemConfiguraton sharedSystemConfiguration].userInfo.id) {
        //myCenter
        PPUserCenterMainPageTableViewController *targetVC = [self.storyboard instantiateViewControllerWithIdentifier:@"PPUserCenterMainPageTableViewController"];
        [self.navigationController pushViewController:targetVC animated:YES];
    }else{
        NSString *url = [PPAPIList getAPIList].PPQueryUserMsgByUserId;
        NSDictionary *params = @{@"userId":@(reply.userId)};
        [httpRequst POST:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
            //
            NSError *err = nil;
            NSDictionary *resultMap = responseObject[@"resultMap"];
            NSDictionary *userDic = resultMap[@"user"];
            PPUserInfo *user = [[PPUserInfo alloc] initWithDictionary:userDic error:&err];
            PPOtherUserCardViewController *targetVC = [self.storyboard instantiateViewControllerWithIdentifier:@"PPOtherUserCardViewController"];
            targetVC.user = user;
            [self.navigationController pushViewController:targetVC animated:YES];
        } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
            
        }];
    }
}

- (void)goInfo
{
    if (self.topic.userId == [PPSystemConfiguraton sharedSystemConfiguration].userInfo.id) {
        //myCenter
        PPUserCenterMainPageTableViewController *targetVC = [self.storyboard instantiateViewControllerWithIdentifier:@"PPUserCenterMainPageTableViewController"];
        [self.navigationController pushViewController:targetVC animated:YES];
    }else{
        PPOtherUserCardViewController *targetVC = [self.storyboard instantiateViewControllerWithIdentifier:@"PPOtherUserCardViewController"];
        targetVC.user = self.topic.userList.firstObject;
        [self.navigationController pushViewController:targetVC animated:YES];
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - UITableView datasource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.commentArray.count + 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (indexPath.row == 0) {
        PPContentTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"contentCell"];
        cell.keywordList = [cell getKeyWordWithKeywordString:self.topic.keyword];
        [cell configCellWithReply:self.topic.content];
        [cell.shareButton addTarget:self action:@selector(share) forControlEvents:UIControlEventTouchUpInside];
        return cell;
    }else{
        PPCommentTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"commentCell"];
        cell.commentAvatar.hidden = NO;
        cell.timeLabel.hidden = NO;
        PPComment *reply = [self.commentArray objectAtIndex:indexPath.row - 1];
        [cell configCellWithReply:reply];
        
        UITapGestureRecognizer *avatarRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(goUserCard:)];
        avatarRecognizer.numberOfTouchesRequired = 1;
        avatarRecognizer.numberOfTapsRequired = 1;
        cell.commentAvatar.tag = indexPath.row;
        cell.commentAvatar.userInteractionEnabled = YES;
        [cell.commentAvatar addGestureRecognizer:avatarRecognizer];
        return cell;
    }
}

#pragma mark - UITableView delegate

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        return [PPContentTableViewCell getCellHeightWithReply:self.topic.content];
    }else{
        PPComment *reply = [self.commentArray objectAtIndex:indexPath.row - 1];
        return [PPCommentTableViewCell getCellHeightWithReply:reply];
    }
}

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
    
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row == 0) {
        //直接评论
        self.replyTargetId = 0;
    }else{
        //回复
        PPComment *reply = [self.commentArray objectAtIndex:indexPath.row - 1];
        self.replyTargetId = reply.userId;
    }
    [self.addCommentTF becomeFirstResponder];
    [tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                animated:YES];
    
}

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row != 0 ) {
        PPComment *deleteReply = [self.commentArray objectAtIndex:indexPath.row - 1];
        if (deleteReply.userId == self.config.userInfo.id) {
            return  YES;
        }
    }
    return NO;
    
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row != 0) {
        if (editingStyle == UITableViewCellEditingStyleDelete) {
            PPComment *deleteReply = [self.commentArray objectAtIndex:indexPath.row - 1];
            [self deleteReply:deleteReply];
            [self.commentArray removeObjectAtIndex:indexPath.row - 1];
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
            [self getTopic];
        }
    }
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    if ([self.addCommentTF isFirstResponder]) {
        [self.addCommentTF resignFirstResponder];
    }
}

#pragma mark - Custom IBAction

- (void)share
{
    PPTopicImage *img = self.topic.topicImgList.firstObject;
    
    NSData *data = [NSData dataWithContentsOfURL:[PPImageUrl getImageUrlOriginal:img.img]];
    UIImage *shareImage = [UIImage imageWithData:data];
    
    [UMSocialSnsService presentSnsController:self appKey:@"54a44f54fd98c59ae100082f" shareText:self.topic.content shareImage:shareImage shareToSnsNames:[NSArray arrayWithObjects:UMShareToWechatSession,UMShareToWechatTimeline,UMShareToQQ,UMShareToSms,UMShareToSina,UMShareToQzone,UMShareToEmail,nil] delegate:self];
}


- (IBAction)delete:(id)sender {
    [HUD showUIBlockingIndicatorWithText:@"正在删除"];
    NSString *url = [PPAPIList getAPIList].PPDeleteTopicById;
    NSDictionary *params = @{@"userId":@(self.config.userInfo.id),@"topicId":@(self.topic.id)};
    [httpRequst POST:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject){
        NSNumber *processResult = responseObject[@"processResult"];
        if (processResult.boolValue) {
            //删除成功
            [HUD hideUIBlockingIndicator];
            [self.config getTopicListwithComepletion:^{
                //更新首页
                [self.navigationController popViewControllerAnimated:YES];
            }];
        }
    }failure:^(AFHTTPRequestOperation *operation, NSError *error){
        [HUD hideUIBlockingIndicator];
    }];
}


- (IBAction)publicComment:(id)sender {
    if (!self.addCommentTF.text.length > 0) {
        [PPHUD hudShowWithString:@"发布内容不能为空" andView:self.view];
        return;
    }
    NSLog(@"%@",self.addCommentTF.text);
    [HUD showUIBlockingIndicatorWithText:@"正在发布"];
    NSString *url = [PPAPIList getAPIList].PPAddOrReplyComment;
    NSDictionary *params =@{@"content":self.addCommentTF.text,@"topicId":@(self.topic.id),@"userId":@(self.config.userInfo.id),@"targetUserId":@(self.replyTargetId)};
    [httpRequst POST:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject){
        self.addCommentTF.text = @"";
        [self.addCommentTF resignFirstResponder];
        [HUD hideUIBlockingIndicator];
        [self getTopic];
    }failure:^(AFHTTPRequestOperation *operation, NSError *error){
        [HUD hideUIBlockingIndicator];
        [PPHUD hudShowWithString:@"发布失败" andView:self.view];
    }];
}

- (IBAction)like:(id)sender {
    NSString *url = [PPAPIList getAPIList].PPAddTopicLike;
    NSDictionary *params = @{@"userId":@(self.config.userInfo.id),@"topicId":@(self.topic.id)};
    [httpRequst POST:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject){
         [self getTopic];
    }failure:^(AFHTTPRequestOperation *operation, NSError *error){
        
    }];
}

-(void)deleteReply:(PPComment *)reply
{
    NSString *url = [PPAPIList getAPIList].PPDeleteReplyComment;
    NSDictionary *params = @{@"replyId":@(reply.id)};
    [httpRequst POST:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
    }];
}

- (void)getTopic
{
    [HUD showUIBlockingIndicatorWithText:@"正在加载"];
    NSString *url = [PPAPIList getAPIList].PPQueryTopicById;
    NSDictionary *params = @{@"topicId":@(self.topic.id)};
    [httpRequst POST:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSDictionary *resultMap = responseObject[@"resultMap"];
        NSArray *topicArray = [PPTopic arrayOfModelsFromDictionaries:resultMap[@"topic"]];
        PPTopic *topic = topicArray.firstObject;
        self.topic.replyNum = topic.replyNum;
        self.topic.topicLikeNum = topic.topicLikeNum;
        self.commentArray = [self.topic.replyNum mutableCopy];
        self.imageArray = [self.topic.topicImgList mutableCopy];
        [self.commentTableView reloadData];
        //加载view
        [self viewInit];
        [HUD hideUIBlockingIndicator];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HUD hideUIBlockingIndicator];
    }];
}

- (void)showImage
{
    PPImageDisplayViewController *targetVC = [self.storyboard instantiateViewControllerWithIdentifier:@"PPImageDisplayViewController"];
    PPTopic *topic = self.topic;
    targetVC.topic = topic;
    targetVC.index = self.pageControl.currentPage;
    [self.navigationController pushViewController:targetVC animated:YES];
}


#pragma mark - UITextFiled delegate
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [self.addCommentTF resignFirstResponder];
    self.replyTargetId = 0;
    return YES;
}

@end
